<!-- 上传头像裁剪组件 -->
<template>
	<u-popup :show="show" @close="close" @open="open" mode="center">
		<view class="container">
			<bt-cropper ref="cropper" :imageSrc="imageSrc" :ratio="1/1" fileType='png'></bt-cropper>
			<u-button @click="crop">裁切</u-button>
		</view>
	</u-popup>
</template>

<script>
	export default {
		props: {
           show:{
			   type:Boolean,
			   default:false
		   },
		   imageSrc:{
			   type:String,
			   default:''
		   }
		},
		data() {
			return {
				
			}
		},
		methods: {
			crop() {
				this.$refs.cropper.crop().then(([err, res]) => {
					console.log(res,err)
					if (!err) {
						console.log(res,'res')
					} else {
						console.log(err,'失败')
					}
				})
			},
			close(){},
			open(){}
		}
	}
</script>

<style scoped lang="scss">
	.container {
		/** 外层一定要指定大小 */
		width: 100vw;
		height: 600rpx;
	}
</style>
